//
//  EMActionSheet.m
//  ElectronicMall
//
//  Created by 史伟文 on 14/12/30.
//  Copyright (c) 2014年 cczu. All rights reserved.
//

#import "EMActionSheet.h"

@implementation EMActionSheet

-(void) initWithTitle:(NSString *)titleStr andContentView:(UIView *)contentView
{
    UIView *backView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, W(320), H(568))];
    backView.backgroundColor = RGBA(0, 0, 0, 0.5);
    UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeSelf:)];
    [backView addGestureRecognizer:tapGR];
    [self addSubview:backView];
    
    
    UIView *contentBackView =[[UIView alloc]initWithFrame:CGRectMake(0,[UIScreen mainScreen].bounds.size.height-H(275), W(320), H(275))];
    contentBackView.backgroundColor = RGBA(255, 255, 255, 0.9);
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:contentBackView.bounds      byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = contentBackView.bounds;
    maskLayer.path = maskPath.CGPath;
    contentBackView.layer.mask = maskLayer;

    UIImageView *logoLabel = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_logo"]];
    logoLabel.frame = CGRectMake(W(90), H(15), W(140), H(25));
    [contentBackView addSubview:logoLabel];
    
    contentView.frame = CGRectMake(W(15), H(55), W(290), H(216));
    [contentBackView addSubview:contentView];
    NSLog(@"%@", contentBackView.subviews);
    
    
    
//    UILabel *titleLabel =[[UILabel alloc]initWithFrame:CGRectMake(120, 15, 200, 20)];
//    titleLabel.backgroundColor = [UIColor clearColor];
//    titleLabel.font =[UIFont fontWithName:HEITIMEDIUM size:20];
//    titleLabel.textColor = RGB(242, 242, 242);
//    [titleLabel setText:titleStr];
//    [contentBackView addSubview:titleLabel];
    [self addSubview:contentBackView];
}
- (void)removeSelf:(UIGestureRecognizer *)gesture
{
    [self removeActionSheet];
}
- (void)removeActionSheet
{
    [UIView animateWithDuration:0.3 animations:^{
        self.frame=CGRectMake(0,H(568) , W(320), H(568));
    }];
}
@end
